package demo;

import java.util.*;

// 根据字符串前序创建二叉树，并中序遍历
public class Main {
    static class TNode{
        char val;
        TNode left;
        TNode right;
        public TNode(char value){
            this.val = value;
        }
    }

    static int i = 0;

    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        String s = in.nextLine();
        
        TNode root = createTree(s);
        inOrder(root);
    }

    private static TNode createTree(String s){
        char ch = s.charAt(i++);
        if(ch == '#'){
            return null;
        }

        TNode node = new TNode(ch);
        node.left = createTree(s);
        node.right = createTree(s);

        return node;
    }
    private static void inOrder(TNode root){
        if(root == null){
            return;
        }
        System.out.print(root.val + " ");
        inOrder(root.left);
        inOrder(root.right);
    }
}